package controller.converters.reprodutivo;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

import model.vos.reprodutivo.Leitegada;
import controller.services.impl.reprodutivo.JsfLeitegadaService;

public class LeitegadaConverter implements Converter{
	
	public Object getAsObject(FacesContext context,
			UIComponent component, String value)
					throws ConverterException {
		if (value == null) {
			return null;
		}
		return new JsfLeitegadaService()
		.pesquisarPorId(Long.parseLong(value));
	}
	
	public String getAsString(FacesContext context,
			UIComponent component, Object object)
					throws ConverterException {
		if (object == null) {
			return null;
		}
		Leitegada c = (Leitegada) object;
		return c.getId().toString();
	}

}
